$(function () {
	if (url('entname')) {
		vm.q.entname = url('entname');
        vm.getDetails();
	} 
	if (url('type')) {
		vm.q.type = url('type');
	} 
	
    $("#jqGrid").jqGrid({
        url: baseURL + 'ccbusiness/cregisterinfo/list',
        datatype: "json",
        postData: vm.q,
        colModel: [			
			{ label: 'id', name: 'id', index: 'id', width: 50, key: true ,hidden: true},
			{ label: '企业名称', name: 'entname', index: 'entname', width: 100 }, 			
//			{ label: '曾用名', name: 'oldname', index: 'oldname', width: 80 }, 			
//			{ label: '统一社会信用代码', name: 'shxydm', index: 'shxydm', width: 80 }, 			
			{ label: '法定代表人', name: 'frdb', index: 'frdb', width: 40 }, 			
			{ label: '成立日期', name: 'esdate', index: 'esdate', width: 60 }, 			
			{ label: '经营状态', name: 'entstatus', index: 'entstatus', width: 80 }, 			
			{ label: '注册资本（万元）', name: 'regcap', index: 'regcap', width: 60 }, 			
//			{ label: '注册资本币种', name: 'regcapcur', index: 'regcapcur', width: 80 }, 			
//			{ label: '地址', name: 'dom', index: 'dom', width: 80 }, 			
			{ label: '企业类型', name: 'enttype', index: 'enttype', width: 80 }, 			
//			{ label: '经营业务范围', name: 'opscope', index: 'opscope', width: 80 }, 			
//			{ label: '登记机关', name: 'regorg', index: 'regorg', width: 80 }, 			
//			{ label: '经营期限自', name: 'opfrom', index: 'opfrom', width: 80 }, 			
//			{ label: '经营期限至', name: 'opto', index: 'opto', width: 80 }, 			
//			{ label: '核准日期', name: 'apprdate', index: 'apprdate', width: 80 }, 			
//			{ label: '死亡日期', name: 'enddate', index: 'enddate', width: 80 }, 			
//			{ label: '吊销日期', name: 'revdate', index: 'revdate', width: 80 }, 			
//			{ label: '注销日期', name: 'candate', index: 'candate', width: 80 }			
        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
    
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		q:{
			entname: null,
			frdb: '',
			regcap: '',
			enttype: '',
			type: '',
        },
		showList: true,
		title: null,
		holderList : [],
		entChronicleInfoList : [],
        showGraph:{
			data: [{
                name: '企业数据',
                x: 120,
                y: 50
            }, {
                name: '结果数据',
                x: 300,
                y: 50
            }, {
                name: '企业规模',
                x: 50,
                y: 100
            }, {
                name: '资金情况',
                x: 80,
                y: 100
            }, {
                name: '股东信息',
                x: 110,
                y: 100
            }, {
                name: '知识产权',
                x: 140,
                y: 100
            }, {
                name: '资质荣誉',
                x: 50,
                y: 130
            }, {
                name: '发展纪事',
                x: 80,
                y: 130
            }, {
                name: '往期业务投资领域',
                x: 110,
                y: 130
            }, {
                name: '最新资本动态',
                x: 140,
                y: 130
            }],
            links: [{
                source: 0,
                target: 1
            },{
                source: 2,
                target: 0
            },{
                source: 3,
                target: 0
            },{
                source: 4,
                target: 0
            },{
                source: 5,
                target: 0
            },{
                source: 6,
                target: 0
            },{
                source: 7,
                target: 0
            },{
                source: 8,
                target: 0
            },{
                source: 9,
                target: 0
            }],
		},
		cRegisterinfo: {}
	},
	methods: {
		query: function () {
            $("#jqGrid").setGridParam({'page': 1});
			vm.reload();
		},
		details: function (event) {
			var id = getSelectedRow();
			if(id == null){
				return ;
			}
			vm.showList = false;
            vm.title = "详情";
            vm.getInfo(id)
		},
		getDetails: function () {
			vm.showList = false;
            vm.title = "详情";
            $.get(baseURL + "ccbusiness/cregisterinfo/infobyname/"+vm.q.entname, function(r){
                vm.cRegisterinfo = r.cRegisterinfo;
                vm.holderList = r.holderList;
                vm.entChronicleInfoList = r.entChronicleInfoList;
            });
		},
		getInfo: function(id){
			$.get(baseURL + "ccbusiness/cregisterinfo/info/"+id, function(r){
                vm.cRegisterinfo = r.cRegisterinfo;
                vm.holderList = r.holderList;
                vm.entChronicleInfoList = r.entChronicleInfoList;
            });
		},
		reload: function (event) {
			if (url('entname')) {
				window.history.back();
			}else{
				vm.showList = true;
				var page = $("#jqGrid").jqGrid('getGridParam','page');
				$("#jqGrid").jqGrid('setGridParam',{ 
	                postData: vm.q,
	                page:page
	            }).trigger("reloadGrid");
			}
		}
	}
});